<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>{{page.title}}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="icon" type="image/png" href="{{page.favicon}}">
    <link rel="apple-touch-icon-precomposed" href="{{page.appicon}}">
    <meta name="apple-mobile-web-app-title" content="{{page.title}}" />
    <link rel="stylesheet" href="static/css/amazeui.min.css" />
    <link rel="stylesheet" href="static/css/amazeui.datatables.min.css" />
    <link rel="stylesheet" href="static/css/app.css">
    <script src="static/js/jquery.min.js"></script>
    <script src="https://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.js"></script>
</head>

<body data-type="login">
    <script src="static/js/theme.js"></script>

    <div class="am-g tpl-g">
        <!-- 风格切换 -->
        <div class="tpl-skiner">
            <div class="tpl-skiner-toggle am-icon-cog">
            </div>
            <div class="tpl-skiner-content">
                <div class="tpl-skiner-content-title">
                    选择主题
                </div>
                <div class="tpl-skiner-content-bar">
                    <span class="skiner-color skiner-white" data-color="theme-white"></span>
                    <span class="skiner-color skiner-black" data-color="theme-black"></span>
                </div>
            </div>
        </div>
        <div class="tpl-login">
            <div class="tpl-login-content">
                <div class="tpl-login-logo">
                </div>



                <form class="am-form tpl-form-line-form" id="loginform">
                    <div class="am-form-group">
                        <input type="text" class="tpl-form-input" id="username" placeholder="请输入账号">

                    </div>

                    <div class="am-form-group">
                        <input type="password" class="tpl-form-input" id="password" placeholder="请输入密码">

                    </div>


                    <div class="am-form-group">

                        <button type="button" id="login" class="am-btn am-btn-primary  am-btn-block tpl-btn-bg-color-success  tpl-login-btn">提交</button>

                    </div>
                </form>
            </div>
        </div>
    </div>
    <script>
        $('.loginform').find('input').keyup(function(event){
            if(event.keyCode===13){
                $('#login').click()
            }
        });
        $('#login').click(function() {
            $('#login').active = false
            $.getJSON('/mapi/' + $('#username').val() + '/login?password=' + $('#password').val(),function(data){
                alert(data['msg'])
                if (data['state'] == 200){
                    $.cookie('token', data['token']);
                    $.cookie('group', data['group']);
                    $.cookie('username', data['username']);
                    window.location.href = '/main/' + data['username']
                }else{

                }
                $('#login').active = true

            })
        });
    </script>
    <script src="static/js/amazeui.min.js"></script>
    <script src="static/js/app.js"></script>

</body>

</html>